package com.gack.business.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gack.business.service.IndexDataServiceInterface;
import com.gack.helper.common.AjaxJson;
import com.gack.helper.common.abstractobj.ApiController;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping(ApiController.INDEX_DATA)
public class IndexDataController {
	@Autowired
	private IndexDataServiceInterface indexDataServiceInterface;

	
	@ApiOperation("首页数据统计")
	@PostMapping("/indexStatistical")
	public AjaxJson indexStatistical() {
		AjaxJson ajaxJson = new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(indexDataServiceInterface.indexStatistical());
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败");
		}
		return ajaxJson;
	}
	

	@ApiOperation("收入统计 参数：2018")
	@PostMapping("/incomeStatistical")
	public AjaxJson incomeStatistical(Integer year) {
		AjaxJson ajaxJson = new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(indexDataServiceInterface.incomeStatistical(year));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败");
		}
		return ajaxJson;
	}
	
	@ApiOperation("注册人数统计 参数：2018")
	@PostMapping("/registerStatistical")
	public AjaxJson registerStatistical(Integer year) {
		AjaxJson ajaxJson = new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(indexDataServiceInterface.registerStatistical(year));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败");
		}
		return ajaxJson;
	}
	
	@ApiOperation("办公地点统计")
	@PostMapping("/storesStatistical")
	public AjaxJson storesStatistical() {
		AjaxJson ajaxJson = new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(indexDataServiceInterface.storesStatistical());
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败");
		}
		return ajaxJson;
	}
	@ApiOperation("一天内共享办公使用次数 参数：2018-06-22")
	@PostMapping("/storesUseStatistical")
	public AjaxJson storesUseStatistical(String date) {
		AjaxJson ajaxJson = new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(indexDataServiceInterface.storesUseStatistical(date));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败");
		}
		return ajaxJson;
	}
	
	@ApiOperation("一天内视频会议使用次数 参数 2018-06-22")
	@PostMapping("/videoUseStatistical")
	public AjaxJson videoUseStatistical(String date) {
		AjaxJson ajaxJson = new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData(indexDataServiceInterface.videoUseStatistical(date));
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败");
		}
		return ajaxJson;
	}

	
//	@ApiOperation("增加使用量")
/*	@PostMapping("/addStatistical")
	public AjaxJson addStatistical() {
		AjaxJson ajaxJson = new AjaxJson();
		try {
			ajaxJson.setSuccess(true).setStatus(200).setData();
		} catch (Exception e) {
			ajaxJson.setSuccess(false).setStatus(500).setMsg("操作失败");
		}
		return ajaxJson;
	}*/

}
